<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>后台首页 - 添加用户</title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- basic styles -->
		<link href="__STATIC__/assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__STATIC__/assets/css/font-awesome.min.css" />
		<link rel="stylesheet" href="__STATIC__/font-awesome-4.7.0/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="__STATIC__/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />

		<!-- ace styles -->

		<link rel="stylesheet" href="__STATIC__/assets/css/ace.min.css" />
		<link rel="stylesheet" href="__STATIC__/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="__STATIC__/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="__STATIC__/css/public.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="__STATIC__/assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="__STATIC__/assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="__STATIC__/assets/js/html5shiv.js"></script>
		<script src="__STATIC__/assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body style="background:#fff;">

		<style>
			ul {
				list-style-type:none;
				padding:0;
				margin:0;
			}
		</style>

		<form class="form-horizontal col-xs-12" role="form">
			<div class="form-group" style="margin-top:20px">
				<label for="role" class="col-xs-2 control-label" style="text-align:right"><span class="red">*&nbsp;</span>所属角色:</label>
				<div class="col-xs-9">
					<select name="role" class="form-control">
						{volist name="allRole" id="role"}
						<option value="{$role.id}">{$role.title}</option>
						{/volist}
					</select>
				</div>
			</div>
			<div class="form-group" style="margin-top:20px">
				<label for="username" class="col-xs-2 control-label" style="text-align:right"><span class="red">*&nbsp;</span>用户名称:</label>
				<div class="col-xs-9">
					<input type="text" id="username" class="form-control" name="username" value="" />
				</div>
			</div>
			<div class="form-group" style="margin-top:20px">
				<label for="password" class="col-xs-2 control-label" style="text-align:right"><span class="red">*&nbsp;</span>密码:</label>
				<div class="col-xs-9">
					<input type="password" id="password" class="form-control" name="password" value="" />
				</div>
			</div>
			<div class="form-group" style="margin-top:20px">
				<label for="re_password" class="col-xs-2 control-label" style="text-align:right"><span class="red">*&nbsp;</span>确认密码:</label>
				<div class="col-xs-9">
					<input type="password" id="re_password" class="form-control" name="re_password" value="" />
				</div>
			</div>
			<div class="form-group">
				<label for="status" class="col-xs-2 control-label" style="text-align:right"><span class="red">*&nbsp;</span>是否启用:</label>
				<div class="col-xs-9">
					<input id="status" name="status" checked="checked" type="checkbox" class="ace ace-switch ace-switch-5">
					<span class="lbl"></span>
				</div>
			</div>

			<span class="col-xs-2"></span><button type="button" id="send" class="btn btn-primary noborder col-xs-1">提交</button>
		</form>

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script src="__STATIC__/assets/js/jquery-2.0.3.min.js"></script>

		<!-- <![endif]-->

		<!--[if IE]>
<script src="__STATIC__/assets/js/jquery-2.0.3.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='__STATIC__/assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='__STATIC__/assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='__STATIC__/assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="__STATIC__/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="__STATIC__/assets/js/excanvas.min.js"></script>
		<![endif]-->

		<script src="__STATIC__/assets/js/jquery-ui-1.10.3.custom.min.js"></script>

		<!-- ace scripts -->

		<script src="__STATIC__/assets/js/ace-elements.min.js"></script>
		<script src="__STATIC__/assets/js/ace.min.js"></script>
		<script src="__STATIC__/layui-v2.2.45/layui.all.js"></script>

		<!-- inline scripts related to this page -->

		<script type="text/javascript">
			$(function(){
				$('#send').click(function(){
					if($('#username').val() == ''){
						layer.msg('用户名称不能为空',function(){
							$('#username').focus();
						})
						return;
					}
					if($('#password').val() == ''){
						layer.msg('密码不能为空',function(){
							$('#password').focus();
						})
						return;
					}
					if($('#password').val().length < 6){
						layer.msg('密码不能少于6位',function(){
							$('#password').focus();
						})
						return;
					}
					if($('#password').val() != $('#re_password').val()){
						layer.msg('两次输入的密码不一致',function(){
							$('#password').focus();
						})
						return;
					}
					$.ajax({
						type:"post",
						url:"{:url('user/add')}",
						data:$("form").serialize(),
						success:function(msg){
							if(msg=='succ'){
								$('#send').addClass('disabled');
								setTimeout(function(){
									//先得到当前iframe层的索引
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index); //再执行关闭
									parent.location.reload();
								},1900);
								layer.msg('用户添加成功！',{icon:6,time:1500});
							} else if(msg=='error'){
								$('#send').addClass('disabled');
								layer.msg('用户添加失败！',{icon:5,time:1500});
								setTimeout(function(){
									location.reload();
								},1900);
							}else{
								$('#send').addClass('disabled');
								layer.msg(msg,{icon:2,time:1500});
								setTimeout(function(){
									location.reload();
								},1900);
							}
						}
					});
				});

			    var $this = $(this);

			    //垂直
			    if($this.hasClass('vertical')){
			        $this.find(".dn-row-ckx").each( function(i,e){
			            var li          = $(e).children(".dn-level-li") ,
			                len         = li.length ,
			                eachLIWid   = (10/len)*10 + '%';
			            li.width(eachLIWid);
			        })            
			    };




			    var obj = {
			        ckx      : $this.find(":checkbox , .ui-ckx").not(":disabled") ,
			        li       : $this.find(".dn-level-li") ,
			        ckxIcon  : $("span.ui-ckx")         
			    };
			    
			    var tree = $(this).not(".horizontal,.vertical");
			    if(tree){
			        var li = tree.find(".dn-level-li");
			        li.each(function(index, el) {
			            if(!$(el).find(".dn-row-ckx").length>0){
			                $(el).children(".dn-ckx-icon").css({"backgroundPositionX":58});
			            }
			        });
			        
			    }

			    obj.li.find(":checkbox:disabled").prev(".ui-ckx").addClass("disabled");

			    obj.li.on('click', function(event) {
			        if(event.target.tagName === 'LABEL') return ;
			        if(event.target.checked){
			            $(event.currentTarget).children("label").find(obj.ckx).prop("checked",true).prev(".ui-ckx").addClass('active');
			        }else{      
			            //这个判断用于防止兄弟被选中的情况下还冒泡上级取消被选
			            if($(event.currentTarget).children(".dn-row-ckx").find(":checked").length<=0){
			                $(event.currentTarget).children("label").find(obj.ckx).prop("checked",false).prev(".ui-ckx").removeClass('active');
			            }
			        }
			    });

			    $this.find(".dn-ckx-icon").on('click', function(event) {
			        event.stopPropagation();
			        var ul = $(this).siblings('.dn-row-ckx');
			        if(ul.length > 0){
			            ul.slideToggle();
			            $(this).children('i').toggleClass('fa-minus-square-o');
			        };
			    });

			    obj.ckx.on('click', function(event) {
			        if(event.target.checked){
			            $(event.target).closest(obj.li).find(obj.ckx).prop("checked",true).prev(".ui-ckx").addClass('active'); 
			        }else{
			            $(event.target).closest(obj.li).find(obj.ckx).prop("checked",false).prev(".ui-ckx").removeClass('active'); 
			        }
			    });

			    obj.li.children('label').hover(function() {
			        $(this).children('.ui-ckx').addClass('hover');
			    }, function() {
			        $(this).children('.ui-ckx').removeClass('hover');
			    });
			});
		</script>
	<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
</html>

